#include "StdAfx.h"
#include "FieldsCollector.h"



using namespace System;
using namespace System::Data::SQLite;

FieldsCollector::FieldsCollector(void)
{
	
}
array<String^>^ FieldsCollector::ListOfUnique(String^ tablename, String^ column)
{
	SQLiteConnection ^ connection = gcnew SQLiteConnection(String::Format("Data Source={0}; Version=3;", ".//Test.his"));
	connection->Open();
	array<String^>^ result = {""};
	String ^ sql = "SELECT DISTINCT " + column + " FROM " + tablename; //+ " ORDER BY " + column + ";"; 
	SQLiteCommand ^command = gcnew SQLiteCommand(sql, connection);
	SQLiteDataReader ^reader; 
	reader = command->ExecuteReader();
	unsigned int count=0;
	while ( reader->Read()){
		if(count > 0)
			Array::Resize(result, result->Length + 1);
			result[count] = reader[0]->ToString();
			count++;

	}
	connection->Close();
    return result; 
	
}